package horsegame;

import javax.imageio.ImageIO;
import javax.swing.JPanel;
import java.awt.*;
import java.io.File;

public class MyPanel extends JPanel {
    private static final long serialVersionUID = 1L;

    @Override
    protected void paintComponent(Graphics g) {//系统对面板的绘制Graphics画笔工具类
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        try {
            super.paintComponent(g);
            g.setColor(Color.white);
            g.fillRect(0, 0, 800, 400);
            Image img = Toolkit.getDefaultToolkit().getImage("./src/Image/yipima.png");
            //Image img = ImageIO.read(new File("./src/Image/ningguang.jpg"));
            g.drawImage(img, 0, 0, this);
            // g.drawImage(img,0,0,500,500,null);//绘制图片的缩放
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}